//
// Created by mayunxi on 2020/6/11.
//

#ifndef FFMPEG_GPU_DECODER4GPU_H
#define FFMPEG_GPU_DECODER4GPU_H


#include "Decoder.h"

class Decoder4GPU: virtual public Decoder {
public:
    Decoder4GPU(CHANNEL_INFO_SET channel_info):Decoder(channel_info)
    {

    };
    ~Decoder4GPU()
    {

        FreeGpuResource();

    }
    bool init();
    void FreeGpuResource(void);
    int GetPicture();
    static DWORD WINAPI StartFunc(void* Param);


    int hw_decoder_init(AVCodecContext *ctx, const enum AVHWDeviceType type);
    int decode_write(AVCodecContext *avctx, AVPacket *packet);
    //intel
    static AVPixelFormat GetHwFormat(AVCodecContext* ctx, const AVPixelFormat* pix_fmts);
    int HwQsvDecoderInit(AVCodecContext* ctx);
    AVCodecContext* GetQsvDecoder(AVStream* stream);
public:
    AVBufferRef *m_hw_device_ref = NULL;
    enum AVPixelFormat m_hw_pix_fmt = AV_PIX_FMT_NONE;

};

#endif //FFMPEG_GPU_DECODER4GPU_H
